﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Web;

namespace ListItTaxi.Web
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class SilverlightWCFService
    {
        protected SmartService ajax;

        [OperationContract]
        public string AjaxRequestJobLink(string customerName, string mobileNo, string telNo, string pickup, string specialInstruction, string destination,
            double travelDate, int taxiCoy, short vehicleType)
        {
            // Add your operation implementation here
            try {
                ajax = new SmartService();
                return ajax.RequestJob("ABC123", customerName, mobileNo, telNo, pickup, specialInstruction, destination, travelDate, taxiCoy, vehicleType);
            }
            finally {
                ajax.Dispose();
            }            
        }

        [OperationContract]
        public bool Authenticate(string username, string password)
        {
            // Add your operation implementation here
            try
            {
                ajax = new SmartService();
                return ajax.Authenticate(username, password);
            }
            finally
            {
                ajax.Dispose();
            }
        }

        [OperationContract]
        public string AddUser(string username, string password, string email, string passPhrase, string answer)
        {
            // Add your operation implementation here
            ajax = new SmartService();
            return ajax.AddUser(username, password, email, passPhrase, answer);
        }
    }
}
